home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 9 / The PC-SIG Library on CD ROM - Ninth Edition.iso / 2101_200 / DISK2170 / DISK2170.ZIP / PC_EXER.C < prev    next >
Text File  |  1989-11-11  |  2KB  |  82 lines

  1. /*----------------------------------------------------------------------------
  2.  
  3. quick 'n dirty    excercise program for pc_util.c
  4.  
  5. ----------------------------------------------------------------------------*/
  6.  
  7. #include    "stdio.h"
  8. #include    "pc_hedr.h"
  9.  
  10. unsigned char w_buf [4000];            /* window save buffer */
  11.  
  12. /*-----------------------------------------------*/
  13.  
  14. main ()
  15.  
  16. {
  17.     int delay;
  18.     
  19.     cls ();
  20.     paints (0, 0, "Press any key and watch !\n", HII, 25);
  21.     paints (3, 0, "Press <x> for window transfer\n", REB, 30);
  22.     paints (18, 18, " Press <q> to quit\n", REV, 19);
  23.     boxc (14, 69, 10, 10, 0xb1, NOR);
  24.     box2 (15, 70, 8, 8, NOR);
  25.     box1 (16, 71, 6, 6, HII);
  26.     box3 (1, 37, 22, 5, NOR);
  27.  
  28.     while (1)
  29.     {
  30.         char key;
  31.         char scan;
  32.     
  33.         delay = 5000;
  34.         while (delay != 0)
  35.         {
  36.             if (delay == 5000)
  37.             {
  38.                 paints (21, 20, " hello world ! \n", NOR, 16);
  39.                 painta (18, 26, NOR, 1);
  40.                 cursor (25, 80);
  41.             }
  42.             if (delay == 2500)
  43.             {
  44.                 paints (21, 20, " how ya doing ? \n", REV, 16);
  45.                 painta (18, 26, REV, 1);
  46.                 cursor (25, 80);
  47.             }
  48.             delay -= 1;
  49.             if (keybuffer_stat())
  50.             {
  51.                 scan = keybuffer_scan ();    /* get scan code */
  52.                 key = rd_keystroke ();        /* get keystroke & flush keyboard buffer */
  53.                 if (key == 'x')
  54.                     move_box();
  55.  
  56.                 paintc (3, 40, ' ', HII, 16);        /* blank line & set to HII */
  57.                 printf ("ASCII CHAR = %c\n", key);
  58.  
  59.                 paintc (4, 40, ' ', HII, 16);        /* blank line & set to HII */
  60.                 printf ("ASCII CODE = %x\n", key);
  61.  
  62.                 paintc (5, 40, ' ', HII, 16);        /* blank line & set to HII */
  63.                 printf ("SCAN  CODE = %x\n", scan);
  64.  
  65.                 cursor (25, 80);
  66.                 if (key == 'q')
  67.                     exit(0);    /* exit program @ 'q' */
  68.             }
  69.         };
  70.     };
  71. }
  72.  
  73. /*-----------------------------------------------*/
  74.  
  75. move_box ()
  76. {
  77.     window_save (1, 37, 23, 6, w_buf);
  78.     window_restore (10, 0, 23, 6, w_buf);
  79. }
  80.  
  81. /*-----------------------------------------------*/
  82.